Assisted ventilation to match patient respiratory need

ABSTRACT

The apparatus provides for the determination of the instantaneous phase in the respiratory cycle, subject&#39;s average respiration rate and the provision of ventilatory assistance. A microprocessor ( 16 ) receives an airflow signal from a pressure transducer ( 18 ) coupled to a port ( 17 ) at a mask ( 11 ). The microprocessor ( 16 ) controls a servo ( 19 ), that in turn controls the fan motor ( 20 ) and thus the pressure of air delivered by the blower ( 10 ). The blower ( 10 ) is coupled to a subject&#39;s mask (ii) by a conduit ( 12 ). The invention seeks to address the following goals: while the subject is awake and making substantial efforts the delivered assistance should be closely matched in phase with the subject&#39;s efforts; the machine should automatically adjust the degree of assistance to maintain at least a specified minimum ventilation without relying on the integrity of the subject&#39;s chemoreflexes; and it should continue to work correctly in the pesence of large leaks.

FIELD OF THE INVENTION

[0001] The invention relates to methods and apparatus for the provisionof ventilatory assistance matched to a subject's respiratory need. Theventilatory assistance can be for a subject who is either spontaneouslyor non-spontaneously breathing, or moves between these breathing states.The invention is especially suitable for, but not limited to,spontaneously breathing human subjects requiring longterm ventilatoryassistance, particularly during sleep.

BACKGROUND OF THE INVENTION

[0002] Subjects with severe lung disease, chest wall disease,neuromuscular disease, or diseases of respiratory control may requirein-hospital mechanical ventilatory assistance, followed by longterm homemechanical ventilatory assistance, particularly during sleep. Theventilator delivers air or air enriched with oxygen to the subject, viaan interface such as a nosemask, at a pressure that is higher duringinspiration and lower during expiration.

[0003] In the awake state, and while waiting to go to sleep, thesubject's ventilatory pattern is variable in rate and depth. Most knownventilatory devices do not accurately match the amplitude and phase ofmask pressure to the subject's spontaneous efforts, leading todiscomfort or panic. Larger amounts of asynchrony also reduce theefficiency of the device. During sleep, there are changes in the neuralcontrol of breathing as well as the mechanics of the subject's airways,respiratory muscles and chest wall, leading to a need for substantiallyincreased ventilator support. Therefore, unless the device canautomatically adjust the degree of support, the amplitude of deliveredpressure will either be inadequate during sleep, or must be excessive inthe awake state. This is particularly important in subjects withabnormalities of respiratory control, for example centralhypoventilation syndromes, such as Obesity Hypoventilation Syndrome,where there is inadequate chemoreceptor drive, or Cheyne Stokesbreathing such as in patients with severe cardiac failure or after astroke, where there is excessive or unstable chemoreceptor drive.

[0004] Furthermore, during sleep there are inevitably large leaksbetween mask and subject, or at the subject's mouth if this is leftfree. Such leaks worsen the error in matching the phase and magnitude ofthe machine's effort to the subject's needs, and, in the case of mouthleak, reduce the effectiveness of the ventilatory support.

[0005] Ideally a ventilatory assistance device should simultaneouslyaddress the following goals:

[0006] (i) While the subject is awake and making substantial ventilatoryefforts, the delivered assistance should be closely matched in phasewith the patient's efforts.

[0007] (ii) The machine should automatically adjust the degree ofassistance to maintain at least a specified minimum ventilation, withoutrelying on the integrity of the subject's chemoreflexes.

[0008] (iii) It should continue to work correctly in the presence oflarge leaks.

[0009] Most simple home ventilators either deliver a fixed volume, orcycle between two fixed pressures. They do so either at a fixed rate, orare triggered by the patient's spontaneous efforts, or both. All suchsimple devices fail to meet goal (ii) of adjusting the degree ofassistance to maintain at least a given ventilation. They also largelyfail to meet goal (i) of closely matching the subjects respiratoryphase: timed devices make no attempt to synchronize with the subject'sefforts; triggered devices attempt to synchronize the start and end ofthe breath with the subject's efforts, but make no attempt to tailor theinstantaneous pressure during a breath to the subject's efforts.Furthermore, the triggering tends to fail in the presence of leaks, thusfailing goal (iii).

[0010] The broad family of servo-ventilators known for at least 20 yearsmeasure ventilation and adjust the degree of assistance to maintainventilation at or above a specified level, thus meeting goal (ii), butthey still fail to meet goal (i) of closely matching the phase of thesubject's spontaneous efforts, for the reasons given above. No attemptis made to meet goal (iii).

[0011] Proportional assistist ventilation (PAV), as taught by Dr MagdyYounes, for example in Principles and Practice of MechanicalVentilation, chapter 15, aims to tailor the pressure vs time profilewithin a breath to partially or completely unload the subject'sresistive and elastic work, while minimizing the airway pressurerequired to achieve the desired ventilation. During the inspiratoryhalf-cycle, the administered pressure takes the form:

P(t)=P₀+R.f_(RESP)(t)+E.V(t)

[0012] where R is a percentage of the resistance of the airway,f_(RESP)(t) is the instantaneous respiratory airflow at time t, E is apercentage of the elastance of lung and chest wall, and V(t) is thevolume inspired since the start of inspiration to the present moment.During the expiratory half-cycle, V(t) is taken as zero, to producepassive expiration.

[0013] An advantage of proportional assist ventilation duringspontaneous breathing is that the degree of assistance is automaticallyadjusted to suit the subject's immediate needs and their pattern ofbreathing, and is therefore comfortable in the spontaneously breathingsubject. However, there are at least two important disadvantages.Firstly, V(t) is calculated as the integral of flow with respect to timesince the start of inspiration. A disadvantage of calculating V(t) inthis way is that, in the presence of leaks, the integral of the flowthrough the leak will be included in V(t), resulting in anoverestimation of V(t), in turn resulting in a runaway increase in theadministered pressure. This can be distressing to the subject. Secondly,PAV relies on the subject's chemoreceptor reflexes to monitor thecomposition of the arterial blood, and thereby set the level ofspontaneous effort. The PAV device then amplifies this spontaneouseffort. In subjects with abnormal chemoreceptor reflexes, thespontaneous efforts may either cease entirely, or become unrelated tothe composition of the arterial blood, and amplification of theseefforts will yield inadequate ventilation. In patients with existingCheyne Stokes breathing during sleep, PAV will by design amplify thesubject's waxing and waning breathing efforts, and actually make mattersworse by exaggerating the disturbance. Thus PAV substantially meets goal(i) of providing assistance in phase with the subject's spontaneousventilation, but cannot meet goal (ii) of adjusting the depth ofassistance if the subject has inadequate chemoreflexes, and does notsatisfactorily meet goal (iii).

[0014] Thus there are known devices that meet each of The above goals,but there is no device that meets all the goals simultaneously.Additionally, it is desirable to provide improvements over the prior artdirected to any one of the stated goals.

[0015] Therefore, the present invention seeks to achieve, at leastpartially, one or more of the following:

[0016] (i) to match the phase and degree of assistance to the subject'sspontaneous efforts when ventilation is well above a target ventilation,

[0017] (ii) to automatically adjust the degree of assistance to maintainat least a specified minimum average ventilation without relying on theintegrity of the subject's chemoreflexes and to damp out instabilitiesin the spontaneous ventilatory efforts, such as Cheyne Stokes breathing.

[0018] (iii) to provide some immunity to the effects of sudden leaks.

DISCLOSURE OF THE INVENTION

[0019] In what follows, a fuzzy membership function is taken asreturning a value between zero and unity, fuzzy intersection A AND B isthe smaller of A and B, fuzzy union A OR B is the larger of A and B, andfuzzy negation NOT A is 1-A.

[0020] The invention discloses the determination of the instantaneousphase in the respiratory cycle as a continuous variable.

[0021] The invention further discloses a method for calculating theinstantaneous phase in the respiratory cycle including at least thesteps of determining that if the instantaneous airflow is small andincreasing fast, then it is close to start of inspiration, if theinstantaneous airflow is large and steady, then it is close tomid-inspiration, if the instantaneous airflow is small and decreasingfast, then it is close to mid-expiration, if the instantaneous airflowis zero and steady, then it is during an end-expiratory pause, andairflow conditions intermediate between the above are associated withcorrespondingly intermediate phases.

[0022] The invention further discloses a method for determining theinstantaneous phase in the respiratory cycle as a continuous variablefrom 0 to 1 revolution, the method comprising the steps of:

[0023] selecting at least two identifiable features F_(N) of a prototypeflow-vs-time waveform f(t) similar to an expected respiratoryflow-vs-time waveform, and for each said feature:

[0024] determining by inspection the phase φ_(N) in the respiratorycycle for said feature, assigning a weight W_(N) to said phase,

[0025] defining a “magnitude” fuzzy set M_(N) whose membership functionis a function of respiratory airflow, and a “rate of change” fuzzy setC_(N,) whose membership function is a function of the time derivative ofrespiratory airflow, chosen such that the fuzzy intersection M_(N) ANDC_(N) will be larger for points on the generalized prototype respiratorywaveform whose phase is closer to the said feature F_(N) than for pointscloser to all other selected features,

[0026] setting the fuzzy inference rule R_(N) for the selected featureF_(N) to be: If flow is M_(N) and rate of change of flow is C_(N) thenphase=φ_(N), with weight W_(N).

[0027] measuring leak-corrected respiratory airflow,

[0028] for each feature F_(N) calculating fuzzy membership in fuzzy setM_(N) and C_(N),

[0029] for each feature F_(N) applying fuzzy inference rule R_(N) todetermine the fuzzy extent Y_(N)=M_(N) AND C_(N) to which the phase isφ_(N), and

[0030] applying a defuzzification procedure using Y_(N) at phases φ_(N)and weights W_(N) to determine the instantaneous phase φ.

[0031] Preferably the identifiable features include zero crossings,peak, inflection points or plateaus of the prototype flow-vs-timewaveform. Furthermore, said weights can be unity, or chosen to reflectthe anticipated reliability of deduction of the particular feature.

[0032] The invention further discloses a method for calculatinginstantaneous phase in the respiratory cycle as a continuous variable,as described above, in which the step of calculating respiratory airflowincludes a low pass filtering step to reduce non-respiratory noise, inwhich the time constant of the low pass filter is an increasing functionof an estimate of the length of the respiratory cycle.

[0033] The invention further discloses a method for measuring theinstantaneous phase in the respiratory cycle as a continuous variable asdescribed above, in which the defuzzification step includes a correctionfor any phase delay introduced in the step of low pass filteringrespiratory airflow.

[0034] The invention further discloses a method for measuring theaverage respiratory rate, comprising the steps of:

[0035] measuring leak-corrected respiratory airflow,

[0036] from the respiratory airflow, calculating the instantaneous phaseφ in the respiratory cycle as a continuous variable from 0 to 1revolution, calculating the instantaneous rate of change of phase dφ/dt,and

[0037] calculating the average respiratory rate by low pass filteringsaid instantaneous rate of change of phase dφ/dt.

[0038] Preferably, the instantaneous phase is calculated by the methodsdescribed above.

[0039] The invention further discloses a method for providingventilatory assistance in a spontaneously breathing subject, comprisingthe steps, performed at repeated sampling intervals, of:

[0040] ascribing a desired waveform template function Π(φ), with domain0 to 1 revolution and range 0 to 1,

[0041] calculating the instantaneous phase φ in the respiratory cycle asa continuous variable from 0 to 1 revolution,

[0042] selecting a desired pressure modulation amplitude A,

[0043] calculating a desired instantaneous delivery pressure as an endexpiratory pressure plus the desired pressure modulation amplitude Amultiplied by the value of the waveform template function Π(φ) at thesaid calculated phase φ, and

[0044] setting delivered pressure to subject to the desired deliverypressure.

[0045] The invention further discloses a method for providingventilatory assistance in a spontaneously breathing subject as describedabove, in which the step of selecting a desired pressure modulationamplitude is a fixed amplitude.

[0046] The invention further discloses a method for providingventilatory assistance in a spontaneously breathing subject as describedabove, in which the step of selecting a desired pressure modulationamplitude in which said amplitude is equal to an elastance multiplied byan estimate of the subject's tidal volume.

[0047] The invention further discloses a method for providingventilatory assistance in a spontaneously breathing subject as describedabove, in which the step of selecting a desired pressure modulationamplitude comprises the substeps of:

[0048] specifying a typical respiratory rate giving a typical cycletime,

[0049] specifying a preset pressure modulation amplitude to apply atsaid typical respiratory rate,

[0050] calculating the observed respiratory rate giving an observedcycle time, and

[0051] calculating the desired amplitude of pressure modulation as saidpreset pressure modulation amplitude multiplied by said observed cycletime divided by the said specified cycle time.

[0052] The invention further discloses a method for providingventilatory assistance in a spontaneously breathing subject including atleast the step of determining the extent that the subject is adequatelyventilated, to said extent the phase in the respiratory cycle isdetermined from the subject's respiratory airflow, but to the extentthat the subject's ventilation is inadequate, the phase in therespiratory cycle is assumed to increase at a pre-set rate, and settingmask pressure as a function of said phase.

[0053] The invention further discloses a method for providingventilatory assistance in a spontaneously breathing subject, comprisingthe steps of: measuring respiratory airflow, determining the extent towhich the instantaneous phase in the respiratory cycle can be determinedfrom said airflow, to said extent determining said phase from saidairflow but to the extent that the phase in the respiratory cycle cannotbe accurately determined, the phase is assumed to increase at a presetrate, and delivering pressure as a function of said phase.

[0054] The invention further discloses a method for calculating theinstantaneous inspired volume of a subject, operable substantiallywithout run-away under conditions of suddenly changing leak, the methodcomprising the steps of:

[0055] determining respiratory airflow approximately corrected for leak,

[0056] calculating an index J varying from 0 to 1 equal to the fuzzyextent to which said corrected respiratory airflow is large positive forlonger than expected, or large negative for longer than expected,

[0057] identifying the start of inspiration, and

[0058] calculating the instantaneous inspired volume as the integral ofsaid corrected respiratory airflow multiplied by the fuzzy negation ofsaid index J with respect to time, from start of inspiration.

[0059] The invention further discloses a method “A” for providingventilatory assistance in a spontaneously breathing subject, the methodcomprising the steps, performed at repeated sampling intervals, of:

[0060] determining respiratory airflow approximately corrected for leak,

[0061] calculating an index J varying from 0 to 1 equal to the fuzzyextent to which said respiratory airflow is large positive for longerthan expected, or large negative for longer than expected,

[0062] calculating a modified airflow equal to said respiratory airflowmultiplied by the fuzzy negation of said index J,

[0063] identifying the phase in the respiratory cycle,

[0064] calculating the instantaneous inspired volume as the integral ofsaid modified airflow with respect to time, with the integral held atzero during the expiratory portion of the respiratory cycle,

[0065] calculating a desired instantaneous delivery pressure as afunction at least of the said instantaneous inspired volume, and

[0066] setting delivered pressure to subject to the desired deliverypressure.

[0067] The invention further discloses a method “B” for providingventilatory assistance in a spontaneously breathing subject, comprisingthe steps of:

[0068] determining respiratory airflow approximately corrected for leak,

[0069] calculating an index J varying from 0 to 1 equal to the fuzzyextent to which the respiratory airflow is large positive for longerthan expected, or large negative for longer than expected,

[0070] identifying the phase in the respiratory cycle,

[0071] calculating a modified respiratory airflow equal to therespiratory airflow multiplied by the fuzzy negation of said index J,

[0072] calculating the instantaneous inspired volume as the integral ofthe modified airflow with respect to time, with the integral held atzero during the expiratory portion of the respiratory cycle,

[0073] calculating the desired instantaneous delivery pressure as anexpiratory pressure plus a resistance multiplied by the instantaneousrespiratory airflow plus a nonlinear resistance multiplied by therespiratory airflow multiplied by the absolute value of the respiratoryairflow plus an elastance multiplied by the said adjusted instantaneousinspired volume, and

[0074] setting delivered pressure to subject to the desired deliverypressure.

[0075] The invention yet further discloses a method “C” for providingassisted ventilation to match the subject's need, comprising the stepsof:

[0076] describing a desired waveform template function Π(φ) with domain0 to 1 revolution and range 0 to 1,

[0077] determining respiratory airflow approximately corrected for leak.

[0078] calculating an index J varying from 0 to 1 equal to the fuzzyextent to which the respiratory airflow is large positive for longerthan expected, or large negative for longer than expected,

[0079] calculating J_(PEAK) equal to the recent peak of the index J,

[0080] calculating the instantaneous phase in the respiratory cycle,

[0081] calculating a desired amplitude of pressure modulation, chosen toservo-control the degree of ventilation to at least exceed a specifiedventilation,

[0082] calculating a desired delivery pressure as an end expiratorypressure plus the calculated pressure modulation amplitude A multipliedby the value of the waveform template function Π(φ) at the saidcalculated phase φ, and

[0083] setting delivered pressure to subject to said desiredinstantaneous delivered pressure.

[0084] The invention yet further discloses a method for providingassisted ventilation to match the subject's need, as described above, inwhich the step of calculating a desired amplitude of pressuremodulation, chosen to servo-control the degree of ventilation to atleast exceed a specified ventilation, comprises the steps of:

[0085] calculating a target airflow equal to twice the targetventilation divided by the target respiratory rate,

[0086] deriving an error term equal to the absolute value of theinstantaneous low pass filtered respiratory airflow minus the targetairflow, and

[0087] calculating the amplitude of pressure modulation as the integralof the error term multiplied by a gain, with the integral clipped to liebetween zero and a maximum.

[0088] The invention yet further discloses a method for providingassisted ventilation to match the subject's need, as described above, inwhich the step of calculating a desired amplitude of pressuremodulation, chosen to servo-control the degree of ventilation to atleast exceed a specified ventilation, comprises the following steps:

[0089] calculating a target airflow equal to twice the targetventilation divided by the target respiratory rate,

[0090] deriving an error term equal to the absolute value of theinstantaneous low pass filtered respiratory airflow minus the targetairflow,

[0091] calculating an uncorrected amplitude of pressure modulation asthe integral of the error term multiplied by a gain, with the integralclipped to lie between zero and a maximum,

[0092] calculating the recent average of said amplitude as the low passfiltered amplitude, with a time constant of several times the length ofa respiratory cycle, and

[0093] setting the actual amplitude of pressure modulation to equal thesaid low pass filtered amplitude multiplied by the recent peak jammingindex J_(PEAK) plus the uncorrected amplitude multiplied by the fuzzynegation of J_(PEAK).

[0094] The invention yet further discloses a method for providingassisted ventilation to match the subject's need, and with particularapplication to subjects with varying respiratory mechanics, insufficientrespiratory drive, abnormal chemoreceptor reflexes, hypoventilationsyndromes, or Cheyne Stokes breathing, combined with the advantages ofproportional assist ventilation adjusted for sudden changes in leak,comprising the steps, performed at repeated sampling intervals, of:

[0095] calculating the instantaneous mask pressure as described formethods “A” or “B” above,

[0096] calculating the instantaneous mask pressure as described formethod “C” above,

[0097] calculating a weighted average of the above two pressures, andsetting the mask pressure to the said weighted average.

[0098] The invention yet further discloses apparatus to give effect toeach one of the methods defined, including one or more transducers tomeasure flow and/or pressure, processor means to perform calculationsand procedures, flow generators for the supply of breathable gas at apressure above atmospheric pressure and gas delivery means to deliverthe breathable gas to a subject's airways.

[0099] The apparatus can include ventilators, ventilatory assistdevices, and CPAP devices including constant level, bi-level orautosetting level devices.

[0100] It is to be understood that while the algorithms embodying theinvention are explained in terms of fuzzy logic, approximations to thesealgorithms can be constructed without the use of the fuzzy logicformalism.

BRIEF DESCRIPTION OF THE DRAWINGS

[0101] A number of embodiments will now be described with reference tothe accompanying drawings in which:

[0102]FIGS. 1a and 1 b show apparatus for fire and second embodiments ofthe invention respectively;

[0103]FIG. 2 is a pressure waveform function Π(φ) used in thecalculation of the desired instantaneous delivery pressure as a functionof the instantaneous phase φ in the respiratory cycle for a firstembodiment of the invention;

[0104]FIG. 3 shows fuzzy membership functions for calculating the degreeof membership in each of five magnitude fuzzy sets (“large negative”,“small negative”, “zero”, “small positive”, and “large positive”) fromthe normalized respiratory airflow according to the first embodiment ofthe invention; and

[0105]FIG. 4 shows fuzzy membership functions for calculating the degreeof membership in each of five rate of change fuzzy sets (“rising fast”,“rising slowly”, “steady”, “falling slowly”, and “falling fast”) fromthe normalized rate of change of airflow according to the firstembodiment of the invention;

[0106]FIG. 5 is a pressure waveform function Π(φ) used in thecalculation of the desired instantaneous delivery pressure as a functionof the instantaneous phase φ in the respiratory cycle for a secondembodiment of the invention;

[0107]FIG. 6 shows calculation of a quantity “lead-in” as a function oftime since the most recent mask off-on transition;

[0108]FIG. 7 shows a fuzzy membership function for fuzzy set A_(I) as afunction of time since the most recent expiratory-to-inspiratory(negative-to-positive) zero crossing of the respiratory airflow signal,such that the membership function measures the extent to which therespiratory airflow has been positive for longer than expected;

[0109]FIG. 8 shows a membership function for fuzzy set B_(I) as afunction of respiratory airflow, such that the membership functionmeasures the extent to which respiratory airflow is large positive;

[0110]FIG. 9 shows an electrical analog of the calculation of a recentpeak jamming index J_(PEAK) from the instantaneous jamming index J;

[0111]FIG. 10 shows the calculation of the time constant τ used in lowpass filtering steps in the calculation of the conductance of a leak, asa function of the recent peak jamming index J_(PEAK).

[0112]FIG. 11 shows a prototypical respiratory flow-time curve, withtime on the x-axis, marking nine features;

[0113]FIG. 12 shows membership functions for fuzzy sets “largenegative”, “small negative”, “zero”, “small positive”, and “largepositive” as functions of normalized respiratory airflow according to asecond embodiment of the invention;

[0114]FIG. 13 shows membership functions for fuzzy sets “falling”,“steady”, and “rising” as functions of normalized rate of change ofrespiratory airflow df/dt according to a second embodiment of theinvention;

[0115]FIG. 14 shows the membership function for fuzzy set “hypopnea”;

[0116]FIG. 15 shows the calculation of the time constant τ forcalculation of normalized recent ventilation, as a function of “servogain” being the gain used for servo-control of minute ventilation to atleast exceed a specified target ventilation;

[0117]FIG. 16 shows the membership function for fuzzy set “hyperpnea” asa function of normalized recent ventilation;

[0118]FIG. 17 shows the membership function for fuzzy set “big leak” asa function of leak;

[0119]FIG. 18 shows the membership functions for fuzzy sets “switchnegative” and “switch positive” as a function of nomalized respiratoryairflow;

[0120]FIG. 19 shows the membership functions for fuzzy sets “insp_phase”and “exp_phase” as functions of the instantaneous phase in therespiratory cycle φ;

[0121]FIG. 20 shows schematically how function W(y), used indefuzzification, calculates the area (shaded) of an isosceles triangleof unit base and height cut off below height y;

[0122] FIGS. 21-26 show actual 60 second flow and pressure tracings fromthe second embodiment of the invention during operation; the verticalscale for flow (heavy trace) is ±1 L/sec, inspiration upwards and thevertical scale for the pressure (light trace) is 0-25 cmH₂O; where:

[0123]FIG. 21 shows that a short central apnea (b) is permitted wheneffort ceases at point (c) after a preceding deep breath (a);

[0124]FIG. 22 shows that a central apnea is not permitted when effortceases at arrow (a) without a preceding deep breath;

[0125]FIG. 23 is recorded with servo gain set high, and shows that acentral apnea is no longer permitted when effort ceases at arrow (a)despite preceding deep breathing;

[0126]FIG. 24 shows automatically increasing end-inspiratory pressure asthe subject makes voluntarily deeper inspiratory efforts;

[0127]FIG. 25 is recorded with a somewhat more square waveform selected,and shows automatically increasing pressure support when the subjectvoluntarily attempts to resist by stiffening the chest wall at point(a);

[0128]FIG. 26 shows that with sudden onset of a sever 1.4 L/sec leak at(a), the flow signal returns to baseline (b) within the span of a singlebreath, and pressure continues to cycle correctly throughout; and

[0129]FIG. 27 shows an actual 60 second tracing showing respiratoryairflow (heavy trace, ±1 L/sec full scale) and instantaneous phase(light trace, 0-1 revolution full scale).

DESCRIPTION OF PREFERRED EMBODIMENTS

[0130] The two embodiments to be described are ventilators that operatein a manner that seeks to simultaneously achieve the three goals statedabove.

[0131] First Embodiment

[0132] Apparatus to give effect to a first embodiment of the apparatusis shown in FIG. 1a. A blower 10 supplies a breathable gas to mask 11 incommunication with the subject's airway via a delivery tube 12 andexhausted via a exhaust diffuser 13. Airflow to the mask 11 is measuredusing a pneumotachograph 14 and a differential pressure transducer 15.The mask flow signal from the transducer 15 is then sampled by amicroprocessor 16. Mask pressure is measured at the port 17 using apressure transducer 18. The pressure signal from the transducer 18 isthen sampled by the microprocessor 16. The microprocessor 16 sends aninstantaneous mask pressure request signal to the servo 19, whichcompares said pressure request signal with actual pressure signal fromthe transducer 18 to the control fan motor 20. The microprocessor can beadjusted via a serial port 21.

[0133] It is to be understood that the mask could equally be replacedwith a tracheotomy tube, endotracheal tube, nasal pillows, or othermeans of making a sealed connection between the air delivery means and asubject's airway.

[0134] The microprocessor 16 is programmed to perform the followingsteps, to be considered in conjunction with Tables 1 and 2. TABLE 1Fuzzy Inference Rules for a first embodiment N Fuzzy Interference RuleFuzzy Phase 1 if size is Zero and rate of Increasing then phase is StartInspiration 2 if size is Small and rate of Increasing then phase isEarly Inspiration Positive change is Slowly 3 if size is Large and rateof Steady then phase is Peak Inspiration Positive change is 4 if size isSmall and rate of Decreasing then phase is Late Inspiration Positivechange is Slowly 5 if size is Zero and rate of Decreasing then phase isStart Expiration change is Fast 6 if size is Small and rate ofDecreasing then phase is Early Expiration Negative change is Slowly 7 ifsize is Large and rate of Steady then phase is Peak Expiration Negativechange is 8 if size is Small and rate of Increasing then phase is LateExpiration Negative change is Slowly 9 if size is Zero and rate ofSteady then phase is Expiratory Pause change is 10 always phase isUnchanged

[0135] TABLE 2 Association of phases with fuzzy rules for a firstembodiment. N Phase Φ 1 Start Inspiration 0.0  2 Early Inspirationvalues 3 Peak Inspiration intermediate between 4 Late Inspiration 0.0and 0.5 5 Start Expiration 0.50 6 Early Expiration values 7 PeakExpiration intermediate between 8 Late Expiration 0.5 and 1.0 9Expiratory Pause 10 Unchanged Φ

[0136] 1. Set desired target values for the duration of inspirationTI_(TGT), duration of expiration TE_(TGT), and minute ventilationV_(TGT). Choose suitable constants P₀ and A_(STD) where P₀ is thedesired end expiratory pressure, and A_(STD) is the desired increase inpressure above P₀ at end inspiration for a breath of duration

TT_(TGT)=TI_(TGT)+TE_(TGT).

[0137] 2. Choose a suitable pressure waveform function Π(φ), such asthat shown in FIG. 2, such that the desired delivery pressure at phase φwill be given by:

P=P₀+AΠ(φ)

[0138] where the amplitude A equals the difference between the endinspiratory pressure and end expiratory pressure. However, otherwaveforms may be suitable for subjects with particular needs.

[0139] 3. Initialize the phase φ in the respiratory cycle to zero, andinitialize the current estimates of actual inspiratory and expiratoryduration TI and TE to TI_(TGT) and TE_(TGT) respectively.

[0140] 4. Initialize the rate of change of phase during inspirationΔφ_(I) between sampling intervals of length T to:

Δφ+=0.5 T/TI_(TGT)

[0141] 5. Initialize the rate of change of phase during expirationΔφ_(E) to:

Δφ_(E)=0.5 T/TE_(TGT)

[0142] 6. Measure the instantaneous respiratory airflow f_(RESP).

[0143] 7. Calculate the average total breath duration TT=TI+TE

[0144] 8. Low pass filter the respiratory airflow with an adjustabletime constant τf, where rf is a fixed small fraction of TT.

[0145] 9. Calculate the instantaneous ventilation V, as half theabsolute value of the respiratory airflow:

V=0.5 /F_(RESP)/

[0146] 10. From the target ventilation V_(TGT) and the measured minuteventilation V, derive an error term V_(ERR), such that large values ofV_(ERR) indicate inadequate ventilation:

V_(ERR)=∫(V_(TGT)V) dt

[0147] 11. Take V_(BAR) as the result of low pass filtering V with atime constant τV_(BAR) which is long compared with TT.

[0148] 12. Calculate a normalized airflow f_(NORM), where

f_(NORM)=f_(RESP)/V_(BAR).

[0149] 13. From f_(NORM), calculate the degree of membership in each ofthe fuzzy sets whose membership functions are shown in FIG. 3.

[0150] 14. Calculate a normalized rate of change df_(NORM)/dφ, equal todf_(NORM)/dt divided by the current estimate of the average respiratorycycle time TT.

[0151] 15. From the normalized rate of change, calculate the degree ofmembership in each of the fuzzy sets shown in FIG. 4.

[0152] 16. For each row N in Table 1, calculate the degree of membershipg_(N) in the fuzzy set shown in the column labelled Fuzzy Phase, byapplying the fuzzy inference rules shown.

[0153] 17. Associate with the result of each of the N rules a phaseφ_(N) as shown in Table 2, noting that φ₁₀ is the current phase φ.

[0154] 18. Increase each of the φ_(N) excepting φ₁₀ by 0.89 τ/TT, tocompensate for the previous low pass filtering step.

[0155] 19. Calculate a new instantaneous phase φ_(INST) as the angle tothe center of gravity of N unit masses at polar coordinates of radiusg_(N) and angle φ_(N) revolutions.

[0156] 20. Calculate the smallest signed difference Δφ_(INST) betweenthe phase estimated in the previous step and the current phase.$\begin{matrix}{{\Delta\Phi}_{INST} = \quad {1 - \left( {{\Delta\Phi}_{INST} - \Phi} \right)}} & {\quad \left( {{\Phi_{INST} - \Phi} > 0.5} \right)} \\{{\Delta\Phi}_{INST} = \quad {\Phi_{INST} - \Phi + 1}} & {\quad \left( {{\Phi_{INST} - \Phi} < {- 0.5}} \right)} \\{{{\Delta\Phi}\quad {INST}} = \quad {\Phi_{INST} - \Phi}} & {\quad ({otherwise})}\end{matrix}$

[0157] 21. Derive a revised estimate Δφ_(REV) equal to a weighted meanof the value calculated in the previous step and the average value(Δφ_(I) or Δφ_(E) as appropriate). $\begin{matrix}{{\Delta\Phi} = \quad {{\left( {1 - W} \right){\Delta\Phi}_{I}} + {W\quad {\Delta\Phi}_{INST}}}} & {\quad \left( {0 < \Phi < 0.5} \right)} \\{{\Delta\Phi} = \quad {{\left( {1 - W} \right){\Delta\Phi}_{I}} + {W\quad {\Delta\Phi}_{INST}}}} & {\quad ({otherwise})}\end{matrix}$

[0158] Smaller values of W will cause better tracking of phase if thesubject is breathing regularly, and larger values will cause bettertracking of phase if the subject is breathing irregularly.

[0159] 22. Derive a blending fraction B, such that the blending fractionis unity if the subject's ventilation is well above V_(TGT), zero if thesubject is breathing near or below V_(TGT), and increasingproportionally from zero to unity as the subject's ventilation increasesthrough an intermediate range.

[0160] 23. Calculate Δφ_(BLEND) influenced chiefly by Δφ calculated instep 21 from the subject's respiratory activity if the subject'sventilation is well above V_(TGT); influenced chiefly by the targetrespiratory duration if the subject is breathing near or below V_(TGT);and proportionally between these two amounts if ventilation is in anintermediate range. $\begin{matrix}{{\Delta\Phi}_{BLEND} = \quad {{B\quad {\Delta\Phi}} + {0.5\left( {1 - B} \right){T/{TI}_{TGT}}}}} & {\quad \left( {0 < \Phi < 0.5} \right)} \\{{\Delta\Phi}_{BLEND} = \quad {{B\quad {\Delta\Phi}} + {0.5\left( {1 - B} \right){T/{TE}_{TGT}}}}} & {\quad ({otherwise})}\end{matrix}$

[0161] 24. Increment φ by Δφ_(BLEND)

[0162] 25. Update the average rate of change of phase (Δφ_(I) or Δφ_(E)as appropriate). $\begin{matrix}{{\Delta\Phi}_{I} = \quad {T/{\tau_{VBAR}\left( {{\Delta\Phi}_{BLEND} - {\Delta\Phi}_{I}} \right)}}} & {\quad \left( {0 < \Phi < 0.5} \right)} \\{{\Delta\Phi}_{E} = \quad {T/{\tau_{VBAR}\left( {{\Delta\Phi}_{BLEND} - {\Delta\Phi}_{E}} \right)}}} & {\quad ({otherwise})}\end{matrix}$

[0163] 26. Recalculate the approximate duration of inspiration TI andexpiration TE:

TI=0.5 T/Δφ_(I)

TE=0.5T/Δφ_(E)

[0164] 27. Calculate the desired mask pressure modulation amplitudeA_(D): $\begin{matrix}{A_{D} = \quad {A_{STD}/2}} & {\quad \left( {{TT} < {{TT}_{STD}/2}} \right)} \\{A_{D} = \quad {2 \cdot S_{STD}}} & {\quad \left( {{TT} > {2 \cdot {TT}_{STD}}} \right)} \\{A_{D} = \quad {A_{STD} \cdot {{TT}/{TT}_{STD}}}} & {\quad ({otherwise})}\end{matrix}$

[0165] 28. From the error term V_(ERR), calculate an additional maskpressure modulation amplitude A_(E): $\begin{matrix}{A_{E} = \quad {K \cdot V_{ERR}}} & {\quad \left( {{{for}\quad V_{ERR}} > 0} \right)} \\{A_{E} = \quad 0} & {\quad ({otherwise})}\end{matrix}$

[0166] where larger values of K will produce a faster but less stablecontrol of the degree of assistance, and smaller values of K willproduce slower but more stable control of the degree of assistance.

[0167] 29. Set the mask pressure P_(MASK) to:

P_(MASK)=P₀+(A_(D)+A_(E)) Π(φ)

[0168] 30. Wait for a sampling interval T, short compared with theduration of a respiratory cycle, and then continue at the step ofmeasuring respiratory airflow.

[0169] Measurement of respiratory airflow

[0170] As follows from above, it is necessary to respiratory airflow,which is a standard procedure to one skilled in the art. In the absenceof leak, respiratory airflow can be measured directly with apneumotachograph placed between the mask and the exhaust. In thepresence of a possible leak, one method disclosed in EuropeanPublication No 0 651 971 incorporated herein by cross-reference is tocalculate the mean flow through the leak, and thence calculate theamount of modulation of the pneumotachograph flow signal due tomodulation of the flow through the leak induced by changing maskpressure, using the following steps:

[0171] 1. Measure the airflow at the mask f_(MASK) using apneumotachograph

[0172] 2. Measure the pressure at the mask P_(MASK)

[0173] 3. Calculate the mean leak as the low pass filtered airflow, witha time constant long compared with a breath.

[0174] 4. Calculate the mean mask pressure as the low pass filtered maskpressure, with a time constant long compared with a breath.

[0175] 5. Calculate the modulation of the flow through the leak as:

δ(leak)=0.5 times the mean leak times the inducing pressure,

[0176] where the inducing pressure is P_(MASK)−mean mask pressure.

[0177] Thence the instantaneous respiratory airflow can be calculatedas:

f_(RESP)=F_(MASK)−mean leak−δ(leak)

[0178] A convenient extension as further disclosed in EP 0 651 971(incorporated herein by cross-reference) is to measure airflowf_(TURBINE) and pressure P_(TURBINE) at the outlet of the turbine, andthence calculate P_(MASK) and f_(MASK) by allowing for the pressure dropdown the air delivery hose, and the airflow lost via the exhaust:

[0179] 1. ΔP_(HOS)E=K₁(F_(TURBINE))−K₂(F_(TURBINE)) ²

[0180] 2. P_(MASK)=P_(TURBINE−ΔP) _(HOSE)

[0181] 3 F_(EXHAUST=K)3{square root}P_(MASK)

[0182] 4 F_(MASK=F) _(TURBINE−F) _(EXHAUST)

[0183] Alternative embodiment

[0184] The following embodiment is particularly applicable to subjectswith varying respiratory mechanics, insufficient respiratory drive,abnormal chemoreceptor reflexes, hypoventilation syndromes, or CheyneStokes breathing, or to subjects with abnormalities of the upper orlower airways, lungs, chest wall, or neuromuscular system.

[0185] Many patients with severe lung disease cannot easily be treatedusing a smooth physiological pressure waveform, because the peakpressure required is unacceptably high, or unachievable with for examplea nose-mask. Such patients may prefer a square pressure waveform, inwhich pressure rises explosively fast at the moment of commencement ofinspiratory effort. This may be particularly important in patients withhigh intrinsic PEEP, in which it is not practicable to overcome theintrinsic PEEP by the use of high levels of extrinsic PEEP or CPAP, dueto the risk of hyperinflation. In such subjects, any delay in triggeringis perceived as very distressing, because of the enormous mis-matchbetween expected and observed support. Smooth waveforms exaggerate theperceived delay, because of the time taken for the administered pressureto exceed the intrinsic PEEP. This embodiment permits the use ofwaveforms varying continuously from square (suitable for patients withfor example severe lung or chest wall disease or high intrinsic PEEP) tovery smooth, suitable for patients with normal lungs and chest wall, butabnormal respiratory control, or neuromuscular abnormalities. Thiswaveform is combined either with or without elements of proportionalassist ventilation (corrected for sudden changes in leak), withservo-control of the minute ventilation to equal or exceed a targetventilation. The latter servo-control has an adjustable gain, so thatsubjects with for example Cheyne Stokes breathing can be treated using avery high servo gain to over-ride their own waxing and waning patterns;subjects with various central hypoventilation syndromes can be treatedwith a low servo gain, so that short central apneas are permitted, forexample to cough, clear the throat, talk, or roll over in bed, but onlyif they follow a previous period of high ventilation; and normalsubjects are treated with an intermediate gain.

[0186] Restating the above in other words:

[0187] The integral gain of the servo-control of the degree ofassistance is adjustable from very fast (0.3 cmH₂O/L/sec/sec) to veryslow. Patients with Cheyne-Stokes breathing have a very high ventilatorycontrol loop gain, but a long control loop delay, leading to hunting. Bysetting the loop gain even higher, the patient's controller isstabilized. This prevents the extreme breathlessness that normallyoccurs during each cycle of Cheyne-Stokes breathing, and this is veryreassuring to the patient. It is impossible for them to have a centralapnea. Conversely, subjects with obesity-hypoventilation syndrome havelow or zero loop gain. They will not feel breathless during a centralapnea. However, they have much mucus and need to cough, and are alsooften very fidgety, needing to roll about in bed. This requires thatthey have central apneas which the machine does not attempt to treat. Bysetting the loop gain very low, the patient is permitted to take acouple of deep breaths and then have a moderate-length central apneawhile coughing, rolling over, etc, but prolonged sustained apneas orhypopneas are prevented.

[0188] Sudden changes in leakage flow are detected and handled using afuzzy logic algorithm. The principle of the algorithm is that the leakfilter time constant is reduced dynamically to the fuzzy extent that theapparent respiratory airflow is a long way from zero for a long timecompared with the patient's expected respiratory cycle length.

[0189] Rather than simply triggering between two states (IPAP, EPAP),the device uses a fuzzy logic algorithm to estimate the position in therespiratory cycle as a continuous variable. The algorithm permits thesmooth pressure waveform to adjust it's rise time automatically to thepatient's instantaneous respiratory pattern.

[0190] The fuzzy phase detection algorithm under normal conditionsclosely tracks the patient's breathing. To the extent that there is ahigh or suddenly changing leak, or the patient's ventilation is low, therate of change of phase (respiratory rate) smoothly reverts to thespecified target respiratory rate. Longer or deeper hypopneas arepermitted to the extent that ventilation is on average adequate. To theextent that the servo gain is set high to prevent Cheyne Stokesbreathing, shorter and shallower pauses are permitted.

[0191] Airflow filtering uses an adaptive filter, which shortens it'stime constant if the subject is breathing rapidly, to give very fastresponse times, and lenthens if the subject is breathing slowly, to helpeliminate cardiogenic artifact.

[0192] The fuzzy changing leak detection algorithm, the fuzzy phasedetection algorithm with its differential handling of brief expiratorypauses, and handling of changing leak, together with the smooth waveformseverally and cooperatively make the system relatively immune to theeffects of sudden leaks.

[0193] By suitably setting various parameters, the system can operate inCPAP, bilevel spontaneous, bilevel timed, proportional assistventilation, volume cycled ventilation, and volume cycledservo-ventilation, and therefore all these modes are subsets of thepresent embodiment. However, the present embodiment permits states ofoperation that can not be achieved by any of the above states, and istherefore distinct from them.

[0194] Notes

[0195] Note 1: in this second embodiment, the names and symbols used forvarious quantities may be different to those used in the firstembodiment.

[0196] Note 2: The term “swing” is used to refer to the differencebetween desired instantaneous pressure at end inspiration and thedesired instantaneous pressure at end expiration.

[0197] Note 3: A fuzzy membership function is taken as returning a valuebetween zero for complete nonmembership and unity for completemembership. Fuzzy intersection A AND B is the lesser of A and B, fuzzyunion A OR B is the larger of A and B, and fuzzy negation NOT A is 1−A.

[0198] Note 4: root(x) is the square root of x, abs(x) is the absolutevalue of x, sign (x) is −1 if x is negative, and +1 otherwise. Anasterisk (*) is used to explicitly indicate multiplication where thismight not be obvious from context.

[0199] Apparatus

[0200] The apparatus for the second embodiment is shown in FIG. 1b. Theblower 110 delivers air under pressure to the mask 111 via the airdelivery hose 112. Exhaled air is exhausted via the exhaust 113 in themask 111. The pneumotachograph 114 and a differential pressuretransducer 115 measure the airflow in the nose 112. The flow signal isdelivered to the microprocessor 116. Pressure at any convenient point117 along the nose 112 is measured using a pressure transducer 118. Theoutput from the pressure transducer 118 is delivered to themicrocontroller 116 and also to a motor servo 119. The microprocessor116 supplies the motor servo 119 with a pressure request signal, whichis then compared with the signal from the pressure transducer 118 tocontrol the blower motor 120. User configurable parameters are loadedinto the microprocessor 116 via a communications port 121, and thecomputed mask pressure and flow can if desired be output via thecommunications port 121.

[0201] Initialization The following user adjustable parameters arespecified and stored: max permissible pressure maximum permissible maskpressure max swing maximum permissible difference between endinspiratory pressure and end expiratory pressure. min swing minimumpermissible difference between end inspiratory pressure and endexpiratory pressure. epap end expiratory pressure min permissiblepressure minimum permissible mask pressure target ventilation minuteventilation is sevo-controlled to equal or exceed this quantity targetfrequency Expected respiratory rate. If the patient is achieving norespiratory airflow, the pressure will cycle at this frequency. targetduty cycle Expected ratio of inspiratory time to cycle time. If thepatient is achieving no respiratory airflow, the pressure will followthis duty cycle. linear resistance andquad resistive unloading = linearresistance * f + quad_resistance * resistance f² sign(f), where f is therespiratory airflow, where sign(x) = −1 for x < 0, +1 otherwise.elastance Unload at least this much elastance servo gain gain forservo-control of minute ventilation to at least exceed targetventilation. waveform time constant Elastic unloading waveform timeconstant as a fraction of inspiratory duration. (0.0 = square wave) hoseresistance ΔP from pressure sensing port to inside mask = hoseresistance times the square of the flow in the intervening tubing.diffuser conductance Flow through the mask exhaust port = diffuserconductance * root mask pressure

[0202] At initialization, the following are calculated from the aboveuser-specified settings:

[0203] The expected duration of a respiratory cycle, of an inspiration,and of an expiration are set respectively to;

[0204] STD T_(TOT=)60/target respiratory rate

[0205] STD T₁=STD T_(TOT)*target duty cycle

[0206] STD T_(E)=STD T_(TOT−STD T) ₁

[0207] The standard rates of change of phase (revolutions per sec)during inspiration and expiration are set respectively to:

[0208] STD dφ_(I=)0.5/STD T_(I)

[0209] STD dφ_(E=)0.5/STD T_(E)

[0210] The instantaneous elastic support at any phase φ in therespiratory cycle is given by:

[0211] PEL(φ)=swing*Π(φ)

[0212] where swing is the pressure at end inspiration minus the pressureat end expiration, $\begin{matrix}{{\prod(\varphi)} = \quad {e^{- 2}{\tau\varphi}}} & {\quad {{{during}\quad {inspiration}},}} \\{\quad {e^{- 4}{\tau \left( {\varphi - 0.5} \right)}}} & {\quad {{during}\quad {expiration}}}\end{matrix}$

[0213] and τ is the user-selectable waveform time constant. If τ=0, thenΠ(φ) is a square wave. The maximum implemented value for τ=0.3,producing a waveform approximately as shown in FIG. 5.

[0214] The mean value of Π(φ) is calculated as follows:$\prod\limits_{BAR}{= {0.5{\int_{0}^{.05}{\prod{(\varphi)\quad {\varphi}}}}}}$

[0215] Operations Performed every 20 Milliseconds

[0216] The following is an overview of routine processing done at 50 Hz:

[0217] measure flow at flow senior and pressure at pressure sensing port

[0218] calculate mask pressure and flow from sensor pressure and flow

[0219] calculate conductance of mask leak

[0220] calculate instantaneous airflow through leak

[0221] calculate respiratory airflow and law pass filtered respiratoryairflow

[0222] calculate mask on-off status and lead-in

[0223] calculate instantaneous and recent peak jamming

[0224] calculate time constant for leak conductance calculations

[0225] calculate phase in respiratory cycle

[0226] update mean rates of change of phase for inspiration andexpiration, lengths of inspiratory and expiratory times, and respiratoryrate

[0227] add hose pressure loss to EPAP pressure

[0228] add resistive unloading

[0229] calculate instantaneous elastic assistance required toservo-control ventilation

[0230] estimate instantaneous elastic recoil pressure using variousassumptions weight and combine estimates

[0231] add servo pressure to yield desired sensor pressure

[0232] servo-control motor speed to achieve desired sensor pressure

[0233] The details of each step will now be explained.

[0234] Measurement of Flow and Pressure

[0235] Flow is measured at the outlet of the blower using apneumotachograph and differential pressure transducer. Pressure ismeasured at any convenient point between the blower outlet and the mask.A humidifier and/or anti-bacterial filter may be inserted between thepressure sensing port and the blower. Flow and pressure are digitized at50 Hz using an AD converter.

[0236] Calculation of mask flow and pressure

[0237] The pressure loss from pressure measuring point to mask iscalculated from the flow at the blower and the (quadratic) resistancefrom measuring point to mask.

[0238] Hose pressure loss=sign(flow)*hose resistance*flow²

[0239] where sign(x)=−1 for x<0, +1 otherwise. The mask pressure is thencalculated by subtracting the hose pressure loss from the measuredsensor pressure:

[0240] Mask pressure=sensor pressure−hose pressure loss

[0241] The flow through the mask exhaust diffuser is calculated from theknown parabolic resistance of the diffuser holes, and the square root ofthe mask pressure:

[0242] diffuser flow=exhaust resistance*sign(mask pressure)*root(abs(mask pressure))

[0243] Finally, the mask flow is calculated:

[0244] mask flow=sensorflow−diffuser flow

[0245] The foregoing describes calculation of mask pressure and flow inthe various treatment modes. In diagnostic mode, the patient is wearingonly nasal cannulae, not a mask. The cannula is plugged into thepressure sensing port. The nasal airflow is calculated from thepressure, after a linearization step, and the mask pressure is set tozero by definition.

[0246] Conductance of leak

[0247] The conductance of the leak is calculated as follows:

[0248] root mask pressure=sign (P_(MASK)) {square root}{square root over(abs (P_(MASK)))}

[0249] LP root mask airflow=low pass filtered root mask airflow

[0250] conductance of leak=LP mask airflow/LP root mask pressure

[0251] The time constant for the two low pass filtering steps isinitialized to 10 seconds and adjusted dynamically thereafter (seebelow).

[0252] Instantaneous flow through leak

[0253] The instantaneous flow through the leak is calculated from theinstantaneous mask pressure and the conductance of the leak:

[0254] instantaneous leak=conductance of leak=root mask pressure

[0255] Respiratory Airflow

[0256] The respiratory airflow is the difference between the flow at themask and the instantaneous leak:

[0257] respiratory airflow=mask flow−instantaneous leak

[0258] Low pass filtered respiratory airflow

[0259] Low pass filter the respiratory airflow to remove cardiogenicairflow and other noise. The time constant is dynamically adjusted to be1/40 of the current estimated length of the respiratory cycle T_(TOT)(initialized to STD_T_(TOT) and updated below). This means that at highrespiratory rates, there is only a short phase delay introduced by thefilter, but at low respiratory rates, there is good rejection ofcardiogenic airflow.

[0260] Mask on/off status

[0261] The mask is assumed to initially be off. An off-on transition istaken as occurring when the respiratory airflow first goes above 0.2L/sec, and an on-off transition is taken as occurring if the maskpressure is less than 2 cmH₂O for more than 1.5 seconds.

[0262] Lead-in

[0263] Lead-in is a quantity that runs from zero if the mask is off, orhas just been donned, to 1.0 if the mask has been on for 20 seconds ormore, as shown in FIG. 6.

[0264] Calculation of instantaneous jamming index, J

[0265] J is the fuzzy extent to which the impedance of the leak hassuddenly changed. It is calculated as the fuzzy extent to which theabsolute magnitude of the respiratory airflow is large for longer thanexpected.

[0266] The fuzzy extent A_(I) to which the airflow has been positive forlonger than expected is calculated from the time τ_(ZI) since the lastpositive-going zero crossing of the calculated respiratory airflowsignal, and the expected duration STD T_(I) of a normal inspiration forthe particular subject, using the fuzzy membership function shown inFIG. 7.

[0267] The fuzzy extent B_(I) to which the airflow is large and positiveis calculated from the instantaneous respiratory airflow using the fuzzymembership function shown in FIG. 8.

[0268] The fuzzy extent I_(I) to which the leak has suddenly increasedis calculated by calculating the fuzzy intersection (lesser) of A_(I)and B_(I).

[0269] Precisely symmetrical calculations are performed for expiration,deriving I_(E) as the fuzzy extent to which the leak has suddenlydecreased. A_(E) is calculated from T_(ZE) and T_(E,) B_(E) iscalculated from minus f_(RESP), and I_(E) is the fuzzy intersection ofA_(E) and B_(E). The instantaneous jamming index J is calculated as thefuzzy union (larger) of indices I_(I) and I_(E).

[0270] Recent peak jamming

[0271] If the instantaneous jamming index is larger than the currentvalue of the recent peak jamming index, then the recent peak jammingindex is set to equal the instantaneous jamming index. Otherwise, therecent peak jamming index is set to equal the instantaneous jammingindex low pass filtered with a the constant of 10 seconds. An electricalanalogy of the calculation is shown in FIG. 9.

[0272] Time constant for leak conductance calculations

[0273] If the conductance of the leak suddenly changes, then thecalculated conductance will initially be incorrect, and will graduallyapproach the correct value at a rate which will be slow if the timeconstant of the low pass filters is long, and fast if the time constantis short. Conversely, if the impedance of the leak is steady, the longerthe time constant the more accurate the calculation of the instantaneousleak. Therefore, it is desirable to lengthen the time constant to theextent that the leak is steady, reduce the time constant to the extentthat the leak has suddenly changed, and to use intermediately longer orshorter time constants if it is intermediately the case that the leak issteady.

[0274] If there is a large and sudden increase in the conductance of theleak, then the calculated respiratory airflow will be incorrect. Inparticular, during apparent inspiration, the calculated respiratoryairflow will be large positive for a time that is large compared withthe expected duration of a normal inspiration. Conversely, if there is asudden decrease in conductance of the leak, then during apparentexpiration the calculated respiratory airflow will be large negative fora time that is large compared with the duration of normal expiration.

[0275] Therefore, the time constant for the calculation of theconductance of the leak is adjusted depending on J_(PEAK), which is ameasure of the fuzzy extent that the leak has recently suddenly changed,as shown in FIG. 10.

[0276] In operation, to the extent that there has recently been a suddenand large change in the leak, J_(PEAK) will be large, and the timeconstant for the calculation of the conductance of the leak will besmall, allowing rapid convergence on the new value of the leakageconductance. Conversely, if the leak is steady for a long time, J_(PEAK)will be small, and the time constant for calculation of the leakageconductance will be large, enabling accurate calculation of theinstantaneous respiratory airflow. In the spectrum of intermediatesituations, where the calculated instantaneous respiratory airflow islarger and for longer periods, J_(PEAK) will be progressively larger,and the time constant for the calculation of the leak will progressivelyreduce. For example, at a moment in time where it is uncertain whetherthe leak is in fact constant, and the subject has merely commenced alarge sigh, or whether in fact there has been a sudden increase in theleak, the index will be of an intermediate value, and the time constantfor calculation of the impedance of the leak will also be of anintermediate value. The advantage is that some corrective action willoccur very early, but without momentary total loss of knowledge of theimpedance of the leak.

[0277] Instantaneous phase in respiratory cycle

[0278] The current phase φ runs from 0 for start of inspiration to 0.5for start of expiration to 1.0 for end expiration=start of nextinspiration. Nine separate features (peaks, zero crossings, plateaux,and some intermediate points) are identified on the waveform, as shownin FIG. 11.

[0279] Calculation of normalized respiratory airflow

[0280] The filtered respiratory airflow is normalized with respect tothe user specified target ventilation as follows:

[0281] standard airflow=target ventilation/7.5 L/min

[0282] f⁷=filtered respiratory airflow/standard airflow

[0283] Next, the fuzzy membership in fuzzy sets large negative, smallnegative, zero, small positive, and large positive, describing theinstantaneous airflow is calculated using the membership functions shownin FIG. 12. For example, if the normalized airflow is 0.25, then theairflow is large negative to extent 0.0, small negative to extent 0.0,zero to extent 0.5, small positive to extent 0.5, large positive toextent 0.00.

[0284] Calculation of normalized rate of change of airflow

[0285] The rate of change of filtered respiratory airflow is calculatedand normalized to a target ventilation of 7.5 L/min at 15 breaths/min asfollows:

[0286] standard df/dt=standard airflow*target frequency/15

[0287] calculate d(filtered airflow)/dt

[0288] low pass filter with a time constant of 8/50 seconds

[0289] normalize by dividing by standard df/dt

[0290] Now evaluate the membership of normalized df/dt in the fuzzy setsfalling, steady, and rising, whose membership functions are shown inFIG. 13.

[0291] Calculation of ventilation, normalized ventilation, and hypopnea

[0292] ventilation=abs(respiratory airflow),

[0293] low pass filtered with a time constant of STD T_(TOT)

[0294] normalized ventilation=ventilation/standard airflow

[0295] Hypopnea is the fuzzy extent to which the normalized ventilationis zero. The membership function for hypopnea is shown in FIG. 14.

[0296] Calculation of recent ventilation, normalized recent ventilation,and hyperpnea

[0297] Recent ventilation is also a low pass filtered abs(respiratoryairflow), but filtered with an adjustable time constant, calculated fromservo gain (specified by the user) as shown in FIG. 15. For example, ifthe servo gain is set to the maximum value of 0.3, the time constant iszero, and recent ventilation equals instantaneous abs(respiratoryairflow). Conversely, if servo gain is zero, the time constant is twiceSTD T_(TOT), the expected length of a typical breath.

[0298] Target absolute airflow 32 2*target ventilation

[0299] normalized recent ventilation=recent ventilation/target absoluteairflow

[0300] Hyperpnea is the fuzzy extent to which the recent ventilation islarge. The membership function for hyperpnea is shown in FIG. 16.

[0301] Big Leak

[0302] The fuzzy extent to which there is a big leak is calculated fromthe membership function shown in FIG. 17.

[0303] Additional fuzzy sets concerned with fuzzy “triggering”

[0304] Membership in fuzzy sets switch negative and switch positive arecalculated from the normalized respiratory airflow using the membershipfunctions shown in FIG. 18, and membership in fuzzy sets ins_phase andexp_phase are calculated from the current phase f using the membershipfunctions shown in FIG. 19.

[0305] Fuzzy Inference Rules for Phase

[0306] Procedure W(y) calculates the area of an isosceles triangle ofunit height and unit base, truncated at height y as shown in FIG. 20. Inthe calculations that follow, recall that fuzzy intersection a AND b isthe smaller of a and b, fuzzy union a OR b is the larger of a and b, andfuzzy negation NOT a is 1−a.

[0307] The first fuzzy rule indicates that lacking any other informationthe phase is to increase at a standard rate. This rule isunconditionally true, and has a very heavy weighting, especially ifthere is a large leak, or there has recently been a sudden change in theleak, or there is a hypopnea.

[0308] W_(STANDARD)=8+16*J_(PEAK+)16*hyopopnea+16*big leak

[0309] The next batch of fuzzy rules correspond to the detection ofvarious features of a typical flow-vs-time curve. These rules all haveunit weighting, and are conditional upon the fuzzy membership in theindicated sets:

[0310] W_(EARLY INSP)=W(rise and small positive)

[0311] W_(PEAK INSP)=W(large positive AND steady AND NOT recent peakjamming)

[0312] W_(LATE INSP)=W(fall AND small negative)

[0313] W_(EARLY EXP)=W(fall AND small negative)

[0314] W_(PEAK EXP)=W(large negative AND steady)

[0315] W_(LATE EXP)=W(rise AND small negative)

[0316] The next rule indicates that there is a legitimate expiratorypause (as opposed to an apnea) if there has been a recent hyperpnea andthe leak has not recently changed:

[0317] W_(PAUSE)=hyperpnea AND NOT J_(PEAK))*W(steady AND zero)

[0318] Recalling that the time constant for hyperpnea gets shorter asservo gain increases, the permitted length of expiratory pause getsshorter and shorter as the servo gain increases, and becomes zero atmaximum servo gain. The rationale for this is that (i) high servo gainplus long pauses in breathing will result in “hunting” of theservo-controller, and (ii) in general high servo gain is used if thesubject's chemoreceptor responses are very brisk, and suppression oflong apneas or hypopneas will help prevent the subject's own internalservo-control from hunting, thereby helping prevent Cheyne-Stokesbreathing.

[0319] Finally, there are two phase-switching rules. During regularquiet breathing at roughly the expected rate, these rules should notstrongly activate, but they are there to handle irregular breathing orbreathing at unusual rates. They have very heavy weightings.

[0320] W_(TRIG INSP)=32 W(expiratory phase AND switch positive)

[0321] W_(TRIG EXP)=32 W(inspiratory phase AND switch negative)

[0322] Defuzzification

[0323] For each of the ten fuzzy rules above, we attach phase angles fN,as shown in Table ZZZ. Note that φN are in revolutions, not radians. Wenow place the ten masses W(N) calculated above at the appropriate phaseangles φN around the unit circle, and take the centroid. Rule N φ_(N)STANDARD 1 current φ TRIG INSP 2 0.00 EARLY INSP 3 0.10 PEAK INSP 4 0.30LATE INSP 5 0.50 TRIG EXP 6 0.5 + 0.05 k EARLY EXP 7 0.5 + 0.10 k PEAKEXP 8 0.5 + 0.20 k LATE EXP 9 0.5 + 0.4 k  EXP PAUSE 10 0.5 + 0.5 k 

where k=STD T_(I)/STD T_(E)

[0324] Note that if the user has entered very short duty cycle, k willbe small. For example a normal duty cycle is 40%, giving k=40/60=0.67.Thus the expiratory peak will be associated with a phase angle of0.5+0.2*0.67=0.63, corresponding 26% of the way into expiratory time,and the expiratory pause would start at 0.5+0.5*0.67=0.83, correspondingto 67% of the way into expiratory time. Conversely, if the duty cycle isset to 20% in a patient with severe obstructive lung disease, features 6through 10 will be skewed or compressed into early expiration,generating an appropriately longer expiratory pause.

[0325] The new estimate of the phase is the centroid, in polarcoordinates, of the above ten rules:${centroid} = {\arctan \left( \frac{\sum{W_{N}\sin \quad \varphi_{N}}}{\sum{W_{N}\cos \quad \varphi_{N}}} \right)}$

[0326] The change in phase dφ from the current phase φ to the centroidis calculated in polar coordinates. Thus if the centroid is 0.01 and thecurrent phase is 0.99, the change in phase is dφ=0.02. Conversely, ifthe centroid is 0.99 and the current phase is 0.01, then dφ=−0.02. Thenew phase is then set to the centroid:

[0327] φ=centroid

[0328] This concludes the calculation of the instantaneous phase in therespiratory cycle φ.

[0329] Estimated mean duration of inspiration, expiration, cycle time,and respiratory rate

[0330] If the current phase is inspiratory (φ<0.5) the estimatedduration of inspiration T_(I) is updated:

[0331] LP(dφ_(I))=low pass filtered dφ with a time constant of 4*STDT_(TOT)

[0332] Clip LP(dφ_(I)) to the range (0.5/STD T_(I))/2 to 4(0.5/STDT_(I))

[0333] T_(I=)0.5/clipped LP(dφI)

[0334] Conversely, if the current phase is expiratory, (φ>=0.5) theestimated duration of expiration T_(E), is updated:

[0335] LP(dφ_(E))=low pass filtered dφ with a time constant of 4*STDT_(TOT)

[0336] Clip LP(φE) to the range (0.5/STD T_(E))/2 to 4(0.5/STD T_(E))

[0337] T_(E)=0.5/clipped LP(dφ_(E))

[0338] The purpose of the clipping is firstly to prevent division byzero, and also so that the calculated T_(I) and T_(E) are never morethan a factor of 4 shorter or a factor of 2 longer than expected.

[0339] Finally, the observed mean duration of a breath T_(TOT) andrespiratory rate RR are:

T_(TOT)=T_(I)=T_(E)

RR=60/T_(TOT)

[0340] Resistive unloading

[0341] The resistive unloading is the pressure drop across the patient'supper and lower airways, calculated from the respiratory airflow andresistance values stored in SRAM.

[0342] f=respiratory airflow truncated to +/−2L/sec

[0343] resistive unloading=airway resistance*f+

[0344] upper airway resistance*f²*sign(f)

[0345] Instantaneous Elastic Assistance

[0346] The purpose of the instantaneous elastic assistance is to providea pressure which balances some or all of the elastic deflating pressuresupplied by the springiness of the lungs and chest wall (instantaneouselastic pressure), plus an additional component required toservo-control the minute ventilation to at least exceed on average apre-set target ventilation. In addition, a minimum swing, alwayspresent, is added to the total. The user-specified parameter elastanceis preset to say 50-75% of the known or estimated elastance of thepatient's lung and chest wall. The various components are calculated asfollows:

[0347] Instantaneous assistance based on minimum pressure swing set byphysician:

[0348] instantaneous minimum assistance=minimum swing*Π(φ)

[0349] Elastic assistance required to servo-control ventilation to equalor exceed target

[0350] The quantity servo swing is the additional pressure modulationamplitude required to servo-control the minute ventilation to at leastequal on average a pre-set target ventilation.

[0351] Minute ventilation is defined as the total number of litresinspired or expired per minute. However, we can't wait for a wholeminute, or even several seconds, to calculate it, because we wish to beable to prevent apneas or hypopneas lasting even a few seconds, and a PIcontroller based on an average ventilation over a few seconds would beeither sluggish or unstable.

[0352] The quantity actually servo-controlled is half the absolute valueof the instantaneous respiratory airflow. A simple clipped integralcontroller with no damping works very satisfactorily. The contoller gainand maximum output ramp up over the first few seconds after putting themask on.

[0353] If we have had a sudden increase in mouth leak, airflow will benonzero for a long time. A side effect is that the ventilation will befalsely measured as well above target, and the amount of servoassistance will be falsely reduced zero. To prevent this, to the extentfuzzy recent peak jamming index is large, we hold the degree of servoassistance at its recent average value, prior to the jamming.

[0354] The algorithm for calculating servo swing is as follows:

[0355] error=target ventilation−abs(respiratory airflow)/2

[0356] servo swing=S error*servo gain*sample interval

[0357] clip servo swing to range 0 to 20 cmH₂O*lead-in

[0358] set recent servo swing=servo swing low pass filtered with a timeconstant of 25 sec.

[0359] clip servo swing to be at most J_(PEAK)*recent servo swing

[0360] The instantaneous servo assistance is calculated by multiplyingservo swing by the previously calculated pressure waveform template:

[0361] instantaneous servo assistance=servo swing*Π(φ)

[0362] Estimating instantaneous elastic pressure

[0363] The instantaneous pressure required to unload the elastic work ofinspiring against the user-specified elastance is the specifiedelastance times the instantaneous inspired volume. Unfortunately,calculating instantaneous inspired volume simply by integratingrespiratory airflow with respect to time does not work in practice forthree reasons: firstly leaks cause explosive run-away of theintegration. Secondly, the integrator is reset at the start of eachinspiration, and this point is difficult to detect reliably. Thirdly,and crucially, if the patient is making no efforts, nothing will happen.

[0364] Therefore, four separate estimates are made, and a weightedaverage taken.

[0365] Estimate 1: Exact instantaneous elastic recoil calculated frominstantaneous tidal volume, with a correction for sudden change in leak

[0366] The first estimate is the instantaneous elastic recoil of aspecified elastance at the estimated instantaneous inspired volume,calculated by multiplying the specified elastance by the integral of aweighted respiratory airflow with respect to time, reset to zero if therespiratory phase is expiratory. The respiratory airflow is weighted bythe fuzzy negation of the recent peak jamming index J_(PEAK), to partlyameliorate an explosive run-away of the integral during brief periods ofsudden increase in leak, before the leak detector has had time to adaptto the changing leak. In the case where the leak is very steady,J_(PEAK) will be zero, the weighting will be unity, and the inspiredvolume will be calculated normally and correctly. In the case where theleak increases suddenly, J_(PEAK) will rapidly increase, the weightingwill decrease, and although typically the calculated inspired volumewill be incorrect, the over-estimation of inspired volume will beameliorated. Calculations are as follows:

[0367] Instantaneous volume=integral of respiratory airflow*(I-J_(PEAK))dt

[0368] if phase is expiratory (0.5<φ<1.0 revolutions) reset integral tozero

[0369] estimate 1=instantaneous volume*elastance

[0370] Estimate 2: based on assumption that the tidal volume equals thetarget tidal volume

[0371] The quantity standard swing is the additional pressure modulationamplitude that would unload the specified elastance for a breath of apreset target tidal volume.

[0372] target tidal volume=target ventilation/target frequency

[0373] standard swing=elastance*target tidal volume

[0374] estimate 2=standard swing*529 (φ)

[0375] Estimate 3: based on assumption that the tidal volume equals thetarget tidal volume divided by the observed mean respiratory rare RRcalculated previously.

[0376] Estimate 3=elastance*target ventilation/RR*Π(φ)

[0377] Estimate 4. based on assumption that this breath is much likerecent breaths

[0378] The instantaneous assistance based on the assumption that theelastic work for this breath is similar to that for recent breaths iscalculated as follows;

[0379] LP elastic assistance=instantaneous elastic assistance

[0380] low pass filtered with a time constant of 2 STD T_(TOT)

[0381] estimate 4=LP elastic assistance*Π(φ)/P_(BAR)

[0382] The above algorithm works correctly even if Π(φ) is dynamicallychanged on-the-fly by the user, from square to a smooth or vice versa.For example, if an 8 cmH₂O square wave (Π_(BAR)=1) adequately assiststhe patient, then a sawtooth wave (Π_(BAR)=0.5) will require 16 cmH₂Oswing to produce the same average assistance.

[0383] Best Estimate of Instantaneous Elastic Recoil Pressure

[0384] Next, calculate the pressure required to unload a best estimateof the actual elastic recoil pressure based on a weighted average of theabove, If Π(φ) is set to the smoothest setting, the estimate is basedequally on all the above estimates of instantaneous elastic recoil. IfΠ(φ) is a square wave, the estimate is based on all the above estimatesexcept for estimate 1, because a square wave is maximal at φ=0, whereasestimate 1 is zero at φ=0. Intermediate waveforms are handledintermediately. Quantity smoothness runs from zero for a square wave to1 for a waveform time constant of 0.3 or above.

[0385] smoothness=waveform time constant/0.3

[0386] instantaneous recoil=(smoothness*estimate 1+

[0387] estimate 2+estimate 3+estimate 4)/(smoothness+3)

[0388] Now add the estimates based on minimum and servo swing, truncateso as not to exceed a maximum swing set by the user. Reduce (lead ingradually) if the mask has only just been put on.

[0389] I=instantaneous minimum assistance+

[0390] instantaneous servo assistance +

[0391] instantaneous recoil

[0392] Truncate I to be less than preset maximum permissible swinginstantaneous elastic assistance=I*lead-in

[0393] This completes the calculation of instantaneous elasticassistance.

[0394] Desired pressure at sensor

[0395] desired sensor pressure=epap+hose pressure loss+resistiveunloading+instantaneous elastic assistance

[0396] Servo control of motor speed

[0397] In the final step, the measured pressure at the sensor isservo-controlled to equal the desired sensor pressure, using for examplea clipped pseudodifferential controller to adjust the motor current.Reference can be made to FIG. 1 in this regard.

[0398] Device Performance

[0399] FIGS. 21-27 each show an actual 60 second recording displaying anaspect of the second embodiment. All recordings are from a normalsubject trained to perform the required manoeuvres. Calculatedrespiratory airflow, mask pressure, and respiratory phase are calculatedusing the algorithms disclosed above, output via a serial port, andplotted digitally.

[0400] In FIGS. 21-26 respiratory airflow is shown as the darkertracing, the vertical scale for flow being ±L/sec, inspiration upwards.The vertical scale for the pressure (light trace) is 0.2 cmH₂O.

[0401]FIG. 21 is recorded with the servo gain set to 0.1cmH₂O/L/sec/sec, which is suitable for subjects with normal chemoflexes.The subject is breathing well above the minimum ventilation, and aparticularly deep breath (sigh) is taken at point (a). As is usual,respiratory effort ceases following the sigh, at point (c). The devicecorrectly permits a short central apnea (b), as indicated by the deviceremaining at the end expiratory pressure during the period marked (b).Conversely FIG. 22 shows that if there is no preceding deep breath, whenefforts cease at (a), the pressure correctly continues to cycle, thuspreventing any hypoxia. FIG. 23 is recorded with servo gain set high, aswould be appropriate for a subject with abnormally high chemoreflexessuch as is typically the case with Cheyne-Stokes breathing. Now wheneffort ceases at arrow (a), pressure continues to cycle and a centralapnea is no longer permitted, despite preceding deep breathing. This isadvantageous for preventing the next cycle of Cheyne-Stokes breathing.

[0402] The above correct behaviour is also exhibited by a time modedevice, but is very different to that of a spontaneous mode bileveldevice, or equally of proportional assist ventilation, both of whichwould fail to cycle after all central apneas, regardless ofappropriateness.

[0403]FIG. 24 shows automatically increasing end-inspiratory pressure asthe subject makes voluntarily deeper inspiratory efforts. The desirablebehaviour is in common with PAV, but is different to that of a simplebilevel device, which would maintain a constant level of support despitean increased patient requirement, or to a volume cycled device, whichwould actually decrease support at a time of increasing need.

[0404]FIG. 25 is recorded with a somewhat more square waveform selected.This figure shows automatically increasing pressure support when thesubject voluntarily attempts to resist by stiffening the chest wall atpoint (a). This desirable behaviour is common with PAV and volume cycleddevices, with the expectation that PAV cannot selectively deliver asquarer waveform. It is distinct from a simple bilevel device whichwould not augment the level of support with increasing need.

[0405]FIG. 26 shows that with sudden onset of a severe 1.4 L/sec leak at(a), the flow signal returns to baseline (b) within the span of a singlebreath, and pressure continues to cycle correctly throughout. Althoughtimed mode devices can also continue to cycle correctly in the face ofsudden changing leak, the are unable to follow the subject's respiratoryrate when required (as shown in FIG. 27). Other known bilevel devicesand PAV mis-trigger for longer or shorter periods following onset of asudden sever leak, and PAV can deliver greatly excessive pressures underthese conditions.

[0406]FIG. 27 shows an actual 60 second tracing showing respiratoryairflow (heavy trace±1 /sec full scale) and respiratory phase as acontinuous variable (light trace, 0 to 1 revolution), with highrespiratory rate in the left half of the trace and low respiratory ratein the right half of the trace. This trace demonstrates that theinvention can determine phase as a continuous variable.

[0407] Advantageous aspects of embodiments of the invention.

[0408] Use of phase as a continuous variable.

[0409] In the prior art, phase is taken as a categorical variable, withtwo values: inspiration and expiration. Errors in the detection of startof inspiration and start of expiration produce categorical errors indelivered pressure. Conversely, here, phase is treated as a continuousvariable having values between zero and unity. Thus categorical errorsin measurement of phase are avoided.

[0410] Adjustable filter frequency and allowance for phase delay

[0411] By using a short time constant when the subject is breathingrapidly, and a long time constant when the subject is breathing slowly,the filter introduces a fixed phase delay which is always a smallfraction of a respiratory cycle. Thus unnecessary phase delays can beavoided, but cardiogenic artifact can be rejected in subjects who arebreathing slowly. Furthermore, because phase is treated as a continuousvariable, it is possible to largely compensate for the delay in the lowpass filter.

[0412] Within-breath pressure regulation as a continuous function ofrespiratory phase.

[0413] With all prior art there is an intrusive discontinuous change inpressure, either at the start of inspiration or at the start ofexpiration. Here, the pressure change is continuous, and therefore morecomfortable.

[0414] With proportional assist ventilation, the instantaneous pressureis a function of instantaneous volume into the breath. This means that asudden large leak can cause explosive pressure run-away. Here, whereinstantaneous pressure is a function of instantaneous phase rather thantidal volume, this is avoided.

[0415] Between-breath pressure-regulation as a function of averageinspiratory duration.

[0416] Average inspiratory duration is easier to calculate in thepresence of leak than is tidal volume. By taking advantage of acorrelation between average inspiratory duration and average tidalvolume, it is possible to adjust the amplitude of modulation to suit theaverage tidal volume.

[0417] Provision of a pressure component for unloading turbulent upperairway resistance, and avoiding cardiogenic pressure instabilities.

[0418] Although Younes describes the use of a component of pressureproportional to the square of respiratory airflow to unload theresistance of external apparatus, the resistance of the externalapparatus in embodiments of the present invention is typicallynegligible. Conversely, embodiments of the present invention describestwo uses for such a component proportional to the square of respiratoryairflow that were not anticipated by Younes. Firstly, sleeping subjects,and subjects with a blocked nose, have a large resistance proportionalto the square of airflow, and a pressure component proportional to thesquare of airflow can be used to unload the anatomical upper airwayresistance. Secondly, small nonrespiratory airflow components due toheartbeat or other artifact, when squared, produces negligible pressuremodulation, so that the use of such a component yields relative immunityto such nonrespiratory airflow.

[0419] Smooth transition between spontaneous and controlled breathing

[0420] There is a smooth, seamless gradation from flexibly tracking thesubject's respiratory pattern during spontaneous breathing well abovethe target ventilation, to fully controlling the duration, depth, andphase of breathing if the subject is making no efforts, via atransitional period in which the subject can make progressively smallerchanges to the timing and depth of breathing. A smooth transition avoidscategorization on errors when ventilation is near but not at the desiredthreshold. The advantage is that the transition from spontaneous tocontrolled ventilation occurs unobtrusively to the subject. This can beespecially important in a subject attempting to go to sleep. A similarsmooth transition can occur in the reverse direction, as a subjectawakens and resumes spontaneous respiratory efforts.

1. A method for calculating the instantaneous phase in the respiratory cycle comprising at least the step of determining that if the instantaneous airflow is small and increasing fast, then it is close to start of inspiration, if the instantaneous airflow is large and steady, then it is close to mid-inspiration, if the instantaneous airflow is small and decreasing fast, then it is close to mid-expiration, if the instantaneous airflow is zero and steady, then it is during an end-expiratory pause, and airflow conditions intermediate between the above are associated with correspondingly intermediate phases.
 2. A method for determining the instantaneous phase in the respiratory cycle as a continuous variable from 0 to 1 revolution, the method comprising the steps of: selecting at least two identifiable features F_(N) of a prototype flow-vs-time waveform f(τ) similar to an expected respiratory flow-vs-time waveform, and for each said feature: determining by inspection the phase φN in the respiratory cycle for said feature, assigning a weight W_(N) to said phase, defining a “magnitude” fuzzy set M_(N) whose membership function is a function of respiratory airflow, and a “rate of change” fuzzy set C_(N,) whose membership function is a function of the time derivative of respiratory airflow, chosen such that the fuzzy intersection M_(N) AND C_(N) will be larger for points on the generalized prototype respiratory waveform whose phase is closer to the said feature F_(N) than for points closer to all other selected features, setting the fuzzy inference rule R_(N) for the selected feature F_(N) to be: If flow is M_(N) and rate of change of flow is C_(N) then phase=φN, with weight W_(N). measuring leak-corrected respiratory airflow, for each feature F_(N) calculating fuzzy membership in fuzzy sets M_(N) and C_(N), for each feature F_(N) applying fuzzy inference rule R_(N) to determine the fuzzy extent Y_(N)=M_(N) AND C_(N) to which the phase is φ_(N), and applying a defuzzification procedure using Y_(N) at phases φ_(N) and weights W_(N) to determine the instantaneous phase φ.
 3. A method as claimed in claim 2, whereby the identifiable features include zero crossings, peaks, inflection points or plateaus of the prototype flow-vs-time waveform.
 4. A method as claimed in claim 2, whereby said weights can be unity, or chosen to reflect the anticipated reliability of deduction of the particular feature.
 5. A method as claimed in claim 2, in which the step of calculating respiratory airflow includes a low pass filtering step to reduce non-respiratory noise, in which the time constant of the low pass filter is an increasing function of an estimate of the length of the respiratory cycle.
 6. A method as claimed in claim 2, in which the defuzzification step includes a correction for any phase delay introduced in the step of low pass filtering respiratory airflow.
 7. A method for measuring the average respiratory rate, comprising the steps of: determining leak-corrected respiratory airflow, from the respiratory airflow, calculating the instantaneous phase φ in the respiratory cycle as a continuous variable from 0 to 1 revolution, calculating the instantaneous rate of change of phase dφ/dt, and calculating the average respiratory rate by low pass filtering said instantaneous rate of change of phase dφ/dt.
 8. A method as claimed in claim 7, whereby the instantaneous phase is determined by the method of claim 1 or claim
 2. 9. A method for providing ventilatory assistance in a spontaneously breathing subject, comprising the steps, performed at repeated sampling intervals of: ascribing a desired waveform template function Π(φ), with domain 0 to 1 revolution and range 0 to 1, calculating the instantaneous phase φ in the respiratory cycle as a continuous variable from 0 to 1 revolution, selecting a desired pressure modulation amplitude A, calculating a desired instantaneous delivery pressure as an end expiratory pressure plus the desired pressure modulation amplitude A multiplied by the value of the waveform template function Π(φ) at the said calculated phase φ, and setting delivered pressure to subject to the desired delivery pressure.
 10. A method as claimed in claim 9, whereby step of selecting a desired pressure modulation amplitude is a fixed amplitude.
 11. A method as claimed in claim 9, whereby the step of selecting a desired pressure modulation amplitude in which said amplitude is equal to an elastance multiplied by an estimate of the subject's tidal volume.
 12. A method for providing ventilatory assistance in a spontaneously breathing subject as described above, in which the step of selecting a desired pressure modulation amplitude comprises the substeps of: specifying a typical respiratory rate giving a typical cycle time, specifying a preset pressure modulation amplitude to apply at said typical respiratory rate, calculating the observed respiratory rate giving an observed cycle time, and calculating the desired amplitude of pressure modulation as said preset pressure modulation amplitude multiplied by said observed cycle time divided by the said specified cycle time.
 13. A method for providing ventilatory assistance in a spontaneously breathing subject, including at least the step of determining the extent that the subject is adequately ventilated, to said extent the phase in the respiratory cycle is determined from the subject's respiratory airflow, but to the extent that the subject's ventilation is unadequate, the phase in the respiratory cycle is assumed to increase at a pre-set rate, and setting mask pressure as a function of said phase.
 14. A method for providing ventilatory assistance in a spontaneously breathing subject, comprising the steps of: measuring respiratory airflow, determining the extent to which the instantaneous phase in the respiratory cycle can be determined from said airflow, to said extent determining said phase from said airflow but to the extent that the phase in the respiratory cycle cannot be accurately determined, the phase is assumed to increase at a preset rate, and delivering pressure as a function of said phase.
 15. A method for calculating the instantaneous inspired volume of a subject, operable substantially without run-away under conditions of suddenly changing leak, the method comprising the steps of: determining respiratory airflow approximately corrected for leak, calculating an index J varying from 0 to 1 equal to the fuzzy extent to which said corrected respiratory airflow is large positive for longer than expected, or large negative for longer than expected, identifying the start of inspiration and calculating the instantaneous inspired volume as the integral of said corrected respiratory airflow multiplied by the fuzzy negation of said index J with respect to time, from start of inspiration.
 16. A method for providing ventilatory assistance in a spontaneously breathing subject, the method comprising the steps, performed at repeated sampling intervals, of: determining respiratory airflow approximately corrected for leak, calculating an index J varying from 0 to 1 equal to the fuzzy extent to which said respiratory airflow is large positive for longer than expected, or large negative for longer than expected, calculating a modified airflow equal to said respiratory airflow multiplied by the fuzzy negation of said index J, identifying the phase in the respiratory cycle, calculating the instantaneous inspired volume as the integral of said modified airflow with respect to time, with the integral held at zero during the expiratory portion of the respiratory cycle. calculating a desired instantaneous delivery pressure as a function at least of the said instantaneous inspired volume, and setting delivered pressure to subject to the desired delivery pressure.
 17. A method for providing ventilatory assistance in a spontaneously breathing subject, comprising the steps of: determining respiratory airflow approximately corrected for leak, calculating an index J varying from 0 to 1 equal to the fuzzy extent to which the respiratory airflow is large positive for longer than expected, or large negative for longer than expected, identifying the phase in the respiratory cycle, calculating a modified respiratory airflow equal to the respiratory airflow multiplied by the fuzzy negation of said index J, calculating the instantaneous inspired volume as the integral of the modified airflow with respect to time, with the integral held at zero during the expiratory portion of the respiratory cycle, calculating the desired instantaneous delivery pressure as an expiratory pressure plus a resistance multiplied by the instantaneous respiratory airflow plus a nonlinear resistance multiplied by the respiratory airflow multiplied by the absolute value of the respiratory airflow plus an elastance multiplied by the said adjusted instantaneous inspired volume, and setting delivered pressure to subject to the desired delivery pressure.
 18. A method for providing assisted ventilation to match the subject's need, comprising the steps of: describing a desired waveform template function Π(φ), with domain 0 to 1 revolution and range 0 to 1, determining respiratory airflow approximately corrected for leak, calculating an index J varying from 0 to 1 equal to the fuzzy extent to which the respiratory airflow is large positive for longer than expected, or large negative for longer than expected, calculating J_(PEAK) equal to the recent peak of the index J, calculating the instantaneous phase in the respiratory cycle, calculating a desired amplitude of pressure modulation, chosen to servo-control the degree of ventilation to at least exceed a specified ventilation, calculating a desired delivery pressure as an end expiratory pressure plus the calculated pressure modulation amplitude A multiplied by the value of the waveform template function Π(φ) at the said calculated phase φ, and setting delivered pressure to subject to said desired instantaneous delivered pressure.
 19. A method for providing assisted ventilation to match the subject's need, as claimed in claim 18, in which the step of calculating a desired amplitude of pressure modulation, chosen to servo-control the degree of ventilation to at least exceed a specified ventilation, comprises the steps of: calculating a target airflow equal to twice the target ventilation divided by the target respiratory rate, deriving an error term equal to the absolute value of the instantaneous low pass filtered respiratory airflow minus the target airflow, and calculating the amplitude of pressure modulation as the integral of the error term multiplied by a gain, with the integral clipped to lie between zero and a maximum.
 20. A method for providing assisted ventilation to match the subject's need, as claimed in claim 18, in which the step of calculating a desired amplitude of pressure modulation, chosen to servo-control the degree of ventilation to at least exceed a specified ventilation, comprises the following steps: calculating a target airflow equal to twice the target ventilation divided by the target respiratory rate, deriving an error term equal to the absolute value of the instantaneous low pass filtered respiratory airflow minus the target airflow, calculating an uncorrected amplitude of pressure modulation as the integral of the error term multiplied by a gain, with the integral clipped to lie between zero and a maximum, calculating the recent average of said amplitude as the low pass filtered amplitude, with a time constant of several times the length of a respiratory cycle, and setting the actual amplitude of pressure modulation to equal the said low pass filtered amplitude multiplied by the recent peak jamming index J_(PEAK) plus the uncorrected amplitude multiplied by the fuzzy negation of J_(PEAK).
 21. A method for providing assisted ventilation to match the subject's need, and with particular application to subjects with varying respiratory mechanics, insufficient respiratory drive, abnormal chemoreceptor reflexes, hypoventilation syndromes, or Cheyne Stokes breathing, combined with the advantages of proportional assist ventilation adjusted for sudden changes in leak, comprising the steps, performed at repeated sampling intervals, of: calculating the instantaneous mask pressure as claimed in claims 16 or 17, calculating the instantaneous mask pressure as claimed in claim 18, calculating a weighted average of the two pressures, and setting the mask pressure to the said weighted average. 